/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: NetMsgMatch.cpp
* Summary: 匹配模块协议。
*
* Author: AutoBuild
* Date: --/--
*******************************************************/

#include "NetMsgMatch.h"

namespace Competition
{
	namespace Net
	{
		//Empty class - CSPlayerNumberRequest

		//----------------------------------------

		//Empty class - CSMatchBeginRequest

		//----------------------------------------

		//Empty class - CSMatchCancelRequest

		//----------------------------------------

		CSMatchConfirmRequest::CSMatchConfirmRequest() : State(0)
		{
		}

		int CSMatchConfirmRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			State = DataUtil::ReadByte(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		SCPlayerNumberResponse::SCPlayerNumberResponse() : LobbyNumber(0), FightNumber(0)
		{
		}

		int SCPlayerNumberResponse::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, LobbyNumber);
			i = DataUtil::WriteInt32(buffer, i, FightNumber);
			return i;
		}

		//----------------------------------------

		SCMatchBeginResponse::SCMatchBeginResponse() : Result(0)
		{
		}

		int SCMatchBeginResponse::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteByte(buffer, i, Result);
			return i;
		}

		//----------------------------------------

		MatchPlayerInfo::MatchPlayerInfo() : UserID(0)
		{
		}

		int MatchPlayerInfo::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteString(buffer, i, NickName);
			return i;
		}

		//----------------------------------------

		SCMatchSuccessNotify::SCMatchSuccessNotify() : PlayerCount(0), StartTime(0), WaitTime(0)
		{
		}

		int SCMatchSuccessNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, PlayerCount);
			for (int j = 0; j < PlayerCount; ++j)
			{
				i = PlayerList[j].Pack(buffer, i);
			}
			i = DataUtil::WriteInt64(buffer, i, StartTime);
			i = DataUtil::WriteInt32(buffer, i, WaitTime);
			return i;
		}

		//----------------------------------------

		SCMatchStateNotify::SCMatchStateNotify() : UserID(0), State(0)
		{
		}

		int SCMatchStateNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteByte(buffer, i, State);
			return i;
		}

		//----------------------------------------

		SCMatchResultNotify::SCMatchResultNotify() : Result(0)
		{
		}

		int SCMatchResultNotify::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteByte(buffer, i, Result);
			return i;
		}
	}
}
